Activities
latest
false
- Overview
- UI Automation
- UI-ANA-016 - Pull Open Browser URL
- UI-ANA-017 - ContinueOnError True
- UI-ANA-018 - List OCR/Image Activities
- UI-DBP-006 - Container Usage
- UI-DBP-013 - Excel Automation Misuse
- UI-DBP-030 - Forbidden Variables Usage In Selectors
- ST-DBP-021 - Hardcoded Timeout
- UI-PRR-001 - Simulate Click
- UI-PRR-002 - Simulate Type
- UI-PRR-003 - Open Application Misuse
- UI-PRR-004 - Hardcoded Delays
- UI-REL-001 - Large Idx in Selectors
- UI-SEC-004 - Selector Email Data
- UI-SEC-010 - App/Url Restrictions
- UI-USG-011 - Non Allowed Attributes
- SY-USG-013 - Private File Invoke
- SY-USG-014 - Incorrect Execution Template Placeholders
- Applications and technologies automated with UI Automation
- UiPath Browser Migration Tool
- Computer Vision Recorder
- Click
- Hover
- Type Secure Text
- Send Hotkey
- Type Into
- Check
- Select Item
- Select Multiple Items
- Get Text
- Set Text
- Activate
- Highlight
- Set Focus
- Anchor Base
- Context Aware Anchor
- Find Relative Element
- Indicate On Screen
- Element Exists
- Find Element
- Wait Element Vanish
- Find Children
- Get Ancestor
- Element Scope
- Get Attribute
- Set Clipping Region
- Get Position
- Take Screenshot
- Wait Attribute
- On Element Appear
- On Element Vanish
- Click Text
- Hover Text
- Find Text Position
- Get Full Text
- Get Visible Text
- Extract Structured Data
- Text Exists
- Click OCR Text
- Hover OCR Text
- Get OCR Text
- Find OCR Text Position
- Microsoft OCR
- Microsoft Project Oxford Online OCR
- Microsoft Azure Computer Vision OCR
- Tesseract OCR
- Google Cloud Vision OCR
- OCR Text Exists
- Click Image
- Hover Image
- Find Image Matches
- Image Exists
- Find Image
- Wait Image Vanish
- On Image Appear
- On Image Vanish
- Load Image
- Save Image
- Attach Browser
- Close Tab
- Go Back
- Go Forward
- Go Home
- Inject JS Script
- Navigate To
- Open Browser
- Refresh Browser
- Set Web Attribute
- Attach Window
- Close Window
- Get Active Window
- Hide Window
- Maximize Window
- Minimize Window
- Move Window
- Restore Window
- Show Window
- Export UI Tree
- Invoke ActiveX Method
- Inject .NET Code
- Click Trigger
- Key Press Trigger
- Click Image Trigger
- System Trigger
- Hotkey Trigger
- Mouse Trigger
- Get Event Info
- Monitor Events
- Get Source Element
- Replay User Event
- Block User Input
- Use Foreground
- Element Attribute Change Trigger
- Element State Change Trigger
- Callout
- Copy Selected Text
- Get From Clipboard
- Set To Clipboard
- Close Application
- Open Application
- Start Process
- Get Password
- Tooltip
- Click Picture on Screen
- Click Toolbar Button
- Read Statusbar
- Select Dates in Calendar
- Select Menu Item
- Expand Tree
- Call Transaction
- SAP Logon
- SAP Login
- Table Cell Scope
- SAP Session Attributes Change Trigger
- Expand ALV Tree
- Expand ALV Hierarchical Table
- Use Application/Browser
- Check App State
- Check/Uncheck
- Click
- Extract Table Data
- Get Text
- Get URL
- Go to URL
- Highlight
- Hover
- Keyboard Shortcuts
- Navigate Browser
- Select Item
- Take Screenshot
- Type Into
- Get Attribute
- Get Browser Data
- Set Browser Data
- Mouse Scroll
- Inject Js Script
- Drag and Drop
- For Each UI Element
- Application Event Trigger
- Click Event Trigger
- Keypress Event Trigger
- Set Text
- Check Element
- Fill Form
- Perform browser search and retrieve results using UI Automation APIs
- Web Browsing
- Find Images
- Click Images
- Trigger and Monitor Events
- Create and Override Files
- HTML Pages: Extract and Manipulate Information
- Window Manipulation
- Automated List Selection
- Find and Manipulate Window Elements
- Manage Text Automation
- Load and Process Images
- Manage Mouse Activated Actions
- Automate Application Runtime
- Automated Run of a Local Application
- Browser Navigation
- Web Automation
- Trigger Scope Example
- Computer Vision Local Server
- Mobile Automation
- Release notes
- Project compatibility
- Get Log Types
- Get Logs
- Get Page Source
- Get Device Orientation
- Get Session Identifier
- Install App
- Manage Current App
- Manage Other App
- Open DeepLink
- Open URL
- Mobile Device Connection
- Positional Swipe
- Press Hardware Button
- Set Device Orientation
- Take Screenshot
- Take Screenshot Part
- Element Exists
- Execute Command
- Get Attribute
- Get Selected Item
- Get Text
- Set Selected Item
- Set Text
- Swipe
- Tap
- Type Text
- Draw Pattern
- Terminal
Perform browser search and retrieve results using UI Automation APIs
UI Automation Activities
Last updated Apr 3, 2024
Perform browser search and retrieve results using UI Automation APIs
This tutorial illustrates how to use UI Automation APIs to create an automation that opens the Google search engine, performs a UiPath search, retrieves the result from the official UiPath website, and displays it in the console.
- UiPath Studio 2023.10 or higher
- UiPath.UIAutomation.Activities 23.10.3 or higher
- Visit Using objects in coded automations and learn the methods you can employ for using object repository elements within your coded automation.
- Create a coded workflow by selecting New, and then Coded Workflow from the File group.
- Capture all the UI elements that you want to use in your coded workflow inside
the Object Repository.
For this example you need to capture the following UI elements:
GoogleHomeScreen
- the Google home screen, where you perform the search.googleSearchBar
- the Google search bar where you type the UiPath keyword.
googleResultsScreen
- the screen that shows the first Google results after performing the search.firstPageOfResults
- the part of the screen that includes only the first results.uipathOfficialWebsite
- the result that takes you to the UiPath official website.
- Create a variable for the Google home screen and open it using the Open API.
public class Search : CodedWorkflow { [Workflow] public void Execute() { // 1. Open Google var homeScreen = uiAutomation.Open(ObjectRepository.Descriptors.Google.GoogleHomeScreen);
public class Search : CodedWorkflow { [Workflow] public void Execute() { // 1. Open Google var homeScreen = uiAutomation.Open(ObjectRepository.Descriptors.Google.GoogleHomeScreen); - Type UiPath in the Google search bar, using the TypeInto API.
// 2. Type "UiPath" in the Google search bar homeScreen.TypeInto(ObjectRepository.Descriptors.Google.GoogleHomeScreen.googleSearchBar, "UiPath");
// 2. Type "UiPath" in the Google search bar homeScreen.TypeInto(ObjectRepository.Descriptors.Google.GoogleHomeScreen.googleSearchBar, "UiPath"); - Send the Enter keyboard shortcut to search for the corresponding result,
using the KeyboardShortcut API.
// 3. Send the "Enter" keyboard shortcut to search for the corresponding Google results homeScreen.KeyboardShortcut(ObjectRepository.Descriptors.Google.GoogleHomeScreen.googleSearchBar, "[d(hk)][k(enter)][u(hk)]");
// 3. Send the "Enter" keyboard shortcut to search for the corresponding Google results homeScreen.KeyboardShortcut(ObjectRepository.Descriptors.Google.GoogleHomeScreen.googleSearchBar, "[d(hk)][k(enter)][u(hk)]"); - Focus on the screen with the
Google results, using the Attach API.
Note: You use the Attach API over the Open API when you need to target a specific screen within an application that has already been opened using the Open API. The Attach API prevents unnecessary application launches, ensuring your automation stays on track.
var googleScreen = uiAutomation.Attach(ObjectRepository.Descriptors.Google.googleResultsScreen);
var googleScreen = uiAutomation.Attach(ObjectRepository.Descriptors.Google.googleResultsScreen); - Get the text from the first Google results and print it out in the console,
using the GetText API.
string firstresultsText = googleScreen.GetText(ObjectRepository.Descriptors.Google.googleResultsScreen.firstPageOfResults); Console.WriteLine(firstresultsText);
string firstresultsText = googleScreen.GetText(ObjectRepository.Descriptors.Google.googleResultsScreen.firstPageOfResults); Console.WriteLine(firstresultsText); - Create an If clause that prints out the the text of the first result that
contains the
"https://www.uipath.com"
string within it.// Initialize with an empty string string officialWebsiteUiPath = ""; if (firstresultsText.Contains("https://www.uipath.com")) { officialWebsiteUiPath = googleScreen.GetText(ObjectRepository.Descriptors.Google.googleResultsScreen.uipathOfficialWebsite); } Console.WriteLine(officialWebsiteUiPath);
// Initialize with an empty string string officialWebsiteUiPath = ""; if (firstresultsText.Contains("https://www.uipath.com")) { officialWebsiteUiPath = googleScreen.GetText(ObjectRepository.Descriptors.Google.googleResultsScreen.uipathOfficialWebsite); } Console.WriteLine(officialWebsiteUiPath);
The automation opens the Google search engine in your preferred web browser, performs
a search for UiPath, retrieves the results from the initial page, and
extracts the text from the result that contains the following link:
https://uipath.com
.
To follow the steps of this tutorial and try it out yourself, you can download the following sample project: Goggle Results using UI Automation APIs.